package list_map;


import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        List<String> list=new ArrayList<>();
        List<Integer> list1=new ArrayList<>();
        int n = s.nextInt();
        int m = s.nextInt();
        while ((n--)>0){
            list.add(s.next());
        }
        for(int i=0;i<list.size();i++){
            int c = 0;
            for(int j=0;j<m;j++){
               c+= list.get(i).charAt(j);
            }
            list1.add(c);
        }
        List<Integer> list2=new ArrayList<>(Arrays.asList(new Integer[list1.size()]));
        Collections.copy(list2, list1);
        Collections.sort(list1);
//        System.out.println("list2"+list2);
//        System.out.println("list1"+list1);
        if(list2.equals(list1)){
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }

}
